import { promiseRequest } from "../../../utils/index";
import {apiBaseUrl} from "../../../utils/config";
const app = getApp();
Page({
  data: {
    rewardName:'',
    rewardCode:'',
    nickName:'',
    avatarUrl:'',
    rewardQrcode:''
  },
//页面加载的时候根据openid查询获取用户的手机号和昵称信息
onLoad(query) {
  //根据openid查询当前人的手机号
  let openid = query.lqropenid;
  let actId = query.actId;
  this.getactreceive(actId,openid);
},
onShow(){
},
//查询领奖人兑换码信息
getactreceive(actId, openid) {
  let requestObj = {
    url: '/wxa/actreceive/getRewardCode',
    method: 'post',
    dataobj: { actId: actId, openid: openid },
  };
  promiseRequest(requestObj).then((res) => {
    if (res.code == 200) {
      if (res.data) {
        let rewardCodeUrl = apiBaseUrl + "/wxa/actreceive/getRewardRrcode?rewardCode=" + res.data.rewardCode + "&openid=" + openid + "&actId=" + actId;
        this.setData({
          rewardName: res.data.rewardName,
          rewardCode: res.data.rewardCode,
          nickName: res.data.nickName,
          avatarUrl: res.data.avatarUrl,
          rewardQrcode: rewardCodeUrl
        })
      }
    }
  }).catch((errMsg) => {
  });
},
//查看更多优惠活动
moreshare() {
  wx.switchTab({
    url: '../../tabar/index/index',
  })
},
})